$(document).ready(function() {
	//top.UppTabs.operator = top.getCurrentTagTitle();// 设置用户tab的标题值
	doSearch();
});

function doSearch(){
	var sellerCode = $("#sellerCode").val();
	var s = $('input[name="beginTime"]').val();
	var e = $('input[name="endTime"]').val();
	$("#data_list").datagrid({
		onLoadError : function() {
			uppAjaxError(data);
		},
		onLoadSuccess:function(data){
			$("#export_link").attr('href',contextPath+'/iccard/report/temp/'+data.fileName);
		},
		queryParams : {
			sellerCode : sellerCode,
			beginTime:s,
			endTime:e
		},
		columns : [ [ {
			field : 'merchantDaliyEarningsDetailId',
			title : '',
			hidden : true
		}, {
			field : 'daliyEarningsDate',
			title : '日期',
			formatter : function(value, row, index) {
				var d =new Date(Number(value));
				return d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
			}
		}, {
			field : 'rechargeableCardExpenseAmount',
			title : '销售总额'
		}, {
			field : 'rechargeableCardDicountRate',
			title : '结算折扣率',
			formatter : function(value, row, index){
				return value+"折";
			}
		}, {
			field : 'rechargeableCardHandleAmount',
			title : '应付总额'
		}, {
			field : 'rechargeableCardSettlementAmount',
			title : '实际结算总额'
		}, {
			field : 'rechargeableCardRealTotalEarnings',
			title : '实际收益总额'
		} ] ],
		autoRowHeight : true,
		fitColumns : true,
		pagination : true,
		nowrap : false,
		singleSelect : true,
		rownumbers : true
	});
	//汇总
	$.ajax({
        url: contextPath + '/iccard/report/financial/prepaid/detailSum',
        dataType: "json",
        data: {
			sellerCode : sellerCode,
			beginTime:s,
			endTime:e
		},
        success: function( data ) {
        	$("#collect_amount").text("销售总额 ："+data.salesTotal+"元         结算总额："+data.settlementTotal+"元      实际收益总额 ： "+data.incomeTotal+"元");
        }
      });
}

